<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="Cask Data, Inc." name="author" />
<meta content="HTTP RESTful Interface to the Cask Data Application Platform" name="description" />
<meta content="Copyright © 2014-2017 Cask Data, Inc." name="copyright" />


    <meta name="git_release" content="6.1.1">
    <meta name="git_hash" content="05fbac36f9f7aadeb44f5728cea35136dbc243e5">
    <meta name="git_timestamp" content="2020-02-09 08:22:47 +0800">
    <title>Logging HTTP RESTful API</title>

    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-dynamicscrollspy-4.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/abixTreeList-2.css" type="text/css" />
    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '6.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>

    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="Cask Data Application Platform 6.1.1 Documentation" href="../index.html" />
    <link rel="up" title="CDAP HTTP RESTful API v3" href="index.html" />
    <link rel="next" title="Metadata HTTP RESTful API" href="metadata.html" />
    <link rel="prev" title="Lifecycle HTTP RESTful API" href="lifecycle.html" />
    <!-- block extrahead -->
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <!-- block extrahead end -->

</head>
<body role="document">

<!-- block navbar -->
<div id="navbar" class="navbar navbar-inverse navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <div class="row">
        <div class="navbar-header">
          <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
          <a class="navbar-brand" href="../table-of-contents/../../index.html">
            <span><img alt="CDAP logo" src="../_static/cdap_logo.svg"/></span>
          </a>

          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

          <div class="pull-right">
            <div class="dropdown version-dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                role="button" aria-haspopup="true" aria-expanded="false">
                v 6.1.1 <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                <li><a href="//docs.cdap.io/cdap/5.1.2/en/index.html">v 5.1.2</a></li>
                <li><a href="//docs.cdap.io/cdap/4.3.4/en/index.html">v 4.3.4</a></li>
              </ul>
            </div>
          </div>
          <form class="navbar-form navbar-right navbar-search" action="../search.html" method="get">
            <div class="form-group">
              <div class="navbar-search-image material-icons"></div>
              <input type="text" name="q" class="form-control" placeholder="  Search" />
            </div>
            <input type="hidden" name="check_keywords" value="yes" />
            <input type="hidden" name="area" value="default" />
          </form>

          <div class="collapse navbar-collapse nav-collapse navbar-right navbar-navigation">
            <ul class="nav navbar-nav"><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../index.html">简介</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../guides.html">手册</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link current" href="../table-of-contents/../../reference-manual/index.html">参考</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../faqs/index.html">帮助</a></li>
            </ul>
          </div>

        </div>
      </div>
    </div>
  </div><!-- block navbar end -->
<!-- block main content -->
<div class="main-container container">
  <div class="row"><div class="col-md-2">
      <div id="sidebar" class="bs-sidenav scrollable-y-outside" role="complementary">
<!-- theme_manual: reference-manual -->
<!-- theme_manual_highlight: reference -->
<!-- sidebar_title_link: Reference -->

  <div role="note" aria-label="manuals links"><h3>Reference</h3>
    <ul class="reference-page-menu">
      <nav class="pagenav">
      <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html"> Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../characters.html"> Supported Characters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cli-api.html"> Command Line Interface API</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html"> HTTP RESTful API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="artifact.html">Artifact</a></li>
<li class="toctree-l2"><a class="reference internal" href="configuration.html">Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataset.html">Dataset</a></li>
<li class="toctree-l2"><a class="reference internal" href="lifecycle.html">Lifecycle</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Logging</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html">Metadata</a></li>
<li class="toctree-l2"><a class="reference internal" href="metrics.html">Metrics</a></li>
<li class="toctree-l2"><a class="reference internal" href="monitor.html">Monitor</a></li>
<li class="toctree-l2"><a class="reference internal" href="namespace.html">Namespace</a></li>
<li class="toctree-l2"><a class="reference internal" href="dashboard.html">Dashboard</a></li>
<li class="toctree-l2"><a class="reference internal" href="preferences.html">Preferences</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html">Profile</a></li>
<li class="toctree-l2"><a class="reference internal" href="query.html">Query</a></li>
<li class="toctree-l2"><a class="reference internal" href="reports.html">Reports</a></li>
<li class="toctree-l2"><a class="reference internal" href="security.html">Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="service.html">Service</a></li>
<li class="toctree-l2"><a class="reference internal" href="transactions.html">Transactions</a></li>
<li class="toctree-l2"><a class="reference internal" href="workflow.html">Workflow</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../java-client-api.html"> Java Client API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../javadocs/index.html"> Javadocs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release-notes.html"> 发行说明</a></li>
<li class="toctree-l1"><a class="reference internal" href="../licenses/index.html"> Trademarks, Licenses, and Dependencies</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html"> 术语表</a></li>
<li class="toctree-l1"><a class="reference internal" href="../genindex.html"> Index</a></li>
</ul>
</nav>
    </ul>
  </div></div>
    </div><div class="col-md-8 content" id="main-content">
    
  <div class="section" id="logging-http-restful-api">
<span id="http-restful-api-logging"></span><h1>Logging HTTP RESTful API<a class="headerlink" href="#logging-http-restful-api" title="Permalink to this headline">🔗</a></h1>
<p>Use the CDAP Logging HTTP RESTful API to download the logs of applications and the system,
with the option of formating and filtering the logs that are downloaded, and setting the
log levels of programs at runtime when under Distributed CDAP mode.</p>
<p>Additional details on logging can be found in the <a class="reference external" href="../../../admin-manual/operations/logging.html#logging-monitoring" title="(in Cask Data Application Platform v6.1.1)"><span class="xref std std-ref">管理手册: Logging and Monitoring</span></a>.</p>
<p>All methods or endpoints described in this API have a base URL (typically
<code class="docutils literal notranslate"><span class="pre">http://&lt;host&gt;:11015</span></code> or <code class="docutils literal notranslate"><span class="pre">https://&lt;host&gt;:10443</span></code>) that precedes the resource
identifier, as described in the <a class="reference internal" href="introduction.html#http-restful-api-conventions-base-url"><span class="std std-ref">RESTful API Conventions</span></a>.
These methods return a status code, as listed in the <a class="reference internal" href="introduction.html#http-restful-api-status-codes"><span class="std std-ref">RESTful API  Status Codes</span></a>.</p>
<div class="section" id="downloading-application-logs">
<h2>Downloading Application Logs<a class="headerlink" href="#downloading-application-logs" title="Permalink to this headline">🔗</a></h2>
<p>Logs emitted by a <em>flow</em>, <em>MapReduce</em>, <em>service</em>, <em>Spark</em>, <em>worker</em>, or <em>workflow</em> program running in CDAP can be
downloaded with the Logging HTTP RESTful API. To do that, send an HTTP GET request:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">GET /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/&lt;program-type&gt;/&lt;program-id&gt;/logs?start=&lt;ts&gt;&amp;stop=&lt;ts&gt;</span>
</pre></div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">namespace-id</span></code></td>
<td>Namespace ID</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">app-id</span></code></td>
<td>Name of the application being called</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">program-type</span></code></td>
<td>One of <code class="docutils literal notranslate"><span class="pre">flows</span></code>, <code class="docutils literal notranslate"><span class="pre">mapreduce</span></code>, <code class="docutils literal notranslate"><span class="pre">services</span></code>, <code class="docutils literal notranslate"><span class="pre">spark</span></code>, <code class="docutils literal notranslate"><span class="pre">workers</span></code>, or <code class="docutils literal notranslate"><span class="pre">workflows</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">program-id</span></code></td>
<td>Name of the program being called</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">ts</span></code></td>
<td><em>Start</em> and <em>stop</em> times, given as seconds since the start of the Epoch.</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><th class="stub">HTTP Method</th>
<td><code class="docutils literal notranslate"><span class="pre">GET</span> <span class="pre">/v3/namespaces/default/apps/WordCount/flows/WordCountFlow/</span></code><code class="docutils literal notranslate"><span class="pre">logs?start=1382576400&amp;stop=1382576700</span></code></td>
</tr>
<tr class="row-even"><th class="stub">Description</th>
<td>Return the logs for all the events from the flow <em>WordCountFlow</em> of the <em>WordCount</em>
application in the namespace <em>default</em>,
beginning <code class="docutils literal notranslate"><span class="pre">Thu,</span> <span class="pre">24</span> <span class="pre">Oct</span> <span class="pre">2013</span> <span class="pre">01:00:00</span> <span class="pre">GMT</span></code> and
ending <code class="docutils literal notranslate"><span class="pre">Thu,</span> <span class="pre">24</span> <span class="pre">Oct</span> <span class="pre">2013</span> <span class="pre">01:05:00</span> <span class="pre">GMT</span></code> (five minutes later)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="downloading-application-logs-for-a-run">
<h2>Downloading Application Logs for a Run<a class="headerlink" href="#downloading-application-logs-for-a-run" title="Permalink to this headline">🔗</a></h2>
<p>To download logs for a program run, send an HTTP GET request:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">GET /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/&lt;program-type&gt;/&lt;program-id&gt;/runs/&lt;run-id&gt;/logs?start=&lt;ts&gt;&amp;stop=&lt;ts&gt;</span>
</pre></div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">namespace-id</span></code></td>
<td>Namespace ID</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">app-id</span></code></td>
<td>Name of the application being called</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">program-type</span></code></td>
<td>One of <code class="docutils literal notranslate"><span class="pre">flows</span></code>, <code class="docutils literal notranslate"><span class="pre">mapreduce</span></code>, <code class="docutils literal notranslate"><span class="pre">services</span></code>, <code class="docutils literal notranslate"><span class="pre">spark</span></code>, <code class="docutils literal notranslate"><span class="pre">workers</span></code>, or <code class="docutils literal notranslate"><span class="pre">workflows</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">program-id</span></code></td>
<td>Name of the program being called</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">run-id</span></code></td>
<td>Run id of the program run</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">ts</span></code></td>
<td><em>Start</em> and <em>stop</em> times, given as seconds since the start of the Epoch.</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><th class="stub">HTTP Method</th>
<td><code class="docutils literal notranslate"><span class="pre">GET</span> <span class="pre">/v3/namespaces/default/apps/WordCount/flows/WordCountFlow/</span></code><code class="docutils literal notranslate"><span class="pre">runs/c826e692-ef8c-11e4-953d-d6686e126da6/logs?start=1382576400&amp;stop=1382576700</span></code></td>
</tr>
<tr class="row-even"><th class="stub">Description</th>
<td>Return the logs for all the events from the flow <em>WordCountFlow</em> of the <em>WordCount</em>
application in the namespace <em>default</em> for run c826e692-ef8c-11e4-953d-d6686e126da6,
beginning <code class="docutils literal notranslate"><span class="pre">Thu,</span> <span class="pre">24</span> <span class="pre">Oct</span> <span class="pre">2013</span> <span class="pre">01:00:00</span> <span class="pre">GMT</span></code> and
ending <code class="docutils literal notranslate"><span class="pre">Thu,</span> <span class="pre">24</span> <span class="pre">Oct</span> <span class="pre">2013</span> <span class="pre">01:05:00</span> <span class="pre">GMT</span></code> (five minutes later)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="downloading-system-logs">
<span id="http-restful-api-logging-downloading-system-logs"></span><h2>Downloading System Logs<a class="headerlink" href="#downloading-system-logs" title="Permalink to this headline">🔗</a></h2>
<p>Logs emitted by a system service running in CDAP can be downloaded with the Logging HTTP
API. To do that, send an HTTP GET request:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">GET /v3/system/services/&lt;service-id&gt;/logs?start=&lt;ts&gt;&amp;stop=&lt;ts&gt;</span>
</pre></div>
</div>
<p>where:</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">service-id</span></code></td>
<td>One of <code class="docutils literal notranslate"><span class="pre">appfabric</span></code>, <code class="docutils literal notranslate"><span class="pre">dataset.executor</span></code>, <code class="docutils literal notranslate"><span class="pre">explore.service</span></code>, <code class="docutils literal notranslate"><span class="pre">metrics</span></code>, <code class="docutils literal notranslate"><span class="pre">metrics.processor</span></code>, <code class="docutils literal notranslate"><span class="pre">streams</span></code>, <code class="docutils literal notranslate"><span class="pre">transaction</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">ts</span></code></td>
<td><em>Start</em> and <em>stop</em> times, given as seconds since the start of the Epoch.</td>
</tr>
</tbody>
</table>
<p>Note that the start and stop times are <strong>not</strong> optional.</p>
<p class="rubric">Example</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><th class="stub">HTTP Method</th>
<td><code class="docutils literal notranslate"><span class="pre">GET</span> <span class="pre">/v3/system/services/appfabric/logs?start=1428541200&amp;stop=1428541500</span></code></td>
</tr>
<tr class="row-even"><th class="stub">Description</th>
<td>Return the logs for the <em>AppFabric</em> service
beginning <code class="docutils literal notranslate"><span class="pre">Thu,</span> <span class="pre">09</span> <span class="pre">Apr</span> <span class="pre">2015</span> <span class="pre">01:00:00</span> <span class="pre">GMT</span></code> and
ending <code class="docutils literal notranslate"><span class="pre">Thu,</span> <span class="pre">09</span> <span class="pre">Apr</span> <span class="pre">2015</span> <span class="pre">01:05:00</span> <span class="pre">GMT</span></code> (five minutes later)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="formatting-and-filtering">
<h2>Formatting and Filtering<a class="headerlink" href="#formatting-and-filtering" title="Permalink to this headline">🔗</a></h2>
<div class="section" id="formatting">
<h3>Formatting<a class="headerlink" href="#formatting" title="Permalink to this headline">🔗</a></h3>
<p>The output is, by default, formatted as HTML-embeddable text; that is, characters that
have a special meaning in HTML will be escaped. A line of a log may look like this:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">2013-10-23 18:03:09,793 - INFO [FlowletProcessDriver-source-0-</span>
<span class="go">      executor:c.c.e.c.StreamSource@-1] – source: Emitting line: this is an &amp;amp; character</span>
</pre></div>
</div>
<p><strong>Note:</strong> The context of the log line shows the name of the flowlet (<em>source</em>), its instance number (0) as
well as the original line in the application code. The character <em>&amp;</em> is escaped as <code class="docutils literal notranslate"><span class="pre">&amp;amp;</span></code>; if you don’t desire
this escaping, you can turn it off by adding the parameter <code class="docutils literal notranslate"><span class="pre">&amp;escape=false</span></code> to the request URL.</p>
<p>The text can also be formatted as JSON. To do so, suffix your URL with the parameter
<code class="docutils literal notranslate"><span class="pre">&amp;format=json</span></code>.</p>
</div>
<div class="section" id="filtering">
<h3>Filtering<a class="headerlink" href="#filtering" title="Permalink to this headline">🔗</a></h3>
<p>A filter string can be supplied as an optional parameter. It will filter the returned log entries
to those that match the supplied string.</p>
</div>
</div>
<div class="section" id="changing-system-service-log-levels">
<span id="http-restful-api-logging-changing-system-service-log-levels"></span><h2>Changing System Service Log Levels<a class="headerlink" href="#changing-system-service-log-levels" title="Permalink to this headline">🔗</a></h2>
<p>Log levels can be set for any system service at runtime. Once changed, they can be reset
back to what they were by using the <a class="reference internal" href="#http-restful-api-system-service-logging-resetting"><span class="std std-ref">system service reset endpoint</span></a> shown below.</p>
<p><strong>Note:</strong> Dynamically-changing log levels for system services is only supported under
Distributed CDAP.</p>
<div class="section" id="setting-system-service-log-levels">
<h3>Setting System Service Log Levels<a class="headerlink" href="#setting-system-service-log-levels" title="Permalink to this headline">🔗</a></h3>
<p>To set the log levels of a system service at runtime under Distributed CDAP, submit an
HTTP PUT request:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">PUT /v3/system/services/&lt;service-id&gt;/loglevels</span>
</pre></div>
</div>
<p>with a JSON map in the request body consisting of pairs of logger names and log levels,
such as:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">&#39;{ &quot;io.cdap.cdap&quot;:&quot;ERROR&quot;, &quot;ROOT&quot;:&quot;TRACE&quot; }&#39;</span>
</pre></div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">service-id</span></code></td>
<td>One of <code class="docutils literal notranslate"><span class="pre">appfabric</span></code>, <code class="docutils literal notranslate"><span class="pre">dataset.executor</span></code>, <code class="docutils literal notranslate"><span class="pre">explore.service</span></code>, <code class="docutils literal notranslate"><span class="pre">log.saver</span></code>,
<code class="docutils literal notranslate"><span class="pre">messaging.service</span></code>, <code class="docutils literal notranslate"><span class="pre">metrics</span></code>, <code class="docutils literal notranslate"><span class="pre">metrics.processor</span></code>, <code class="docutils literal notranslate"><span class="pre">streams</span></code>, <code class="docutils literal notranslate"><span class="pre">transaction</span></code></td>
</tr>
</tbody>
</table>
<p>Note that changing the log levels of the <code class="docutils literal notranslate"><span class="pre">appfabric</span></code> service <strong>will also</strong> change the
log levels of the <code class="docutils literal notranslate"><span class="pre">dataset.service</span></code> as they run on the same node.</p>
<p>For example:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">PUT /v3/system/services/metrics.processor/loglevels \</span>
<span class="go">    -d &#39;{ &quot;io.cdap.cdap&quot;:&quot;ERROR&quot;, &quot;ROOT&quot;:&quot;TRACE&quot; }&#39;</span>
</pre></div>
</div>
<p>will update the log levels of the system service <em>metrics.processor</em> with the log level of
<code class="docutils literal notranslate"><span class="pre">io.cdap.cdap</span></code> changed to <code class="docutils literal notranslate"><span class="pre">ERROR</span></code> and the log level of <code class="docutils literal notranslate"><span class="pre">ROOT</span></code> changed to <code class="docutils literal notranslate"><span class="pre">TRACE</span></code>.</p>
</div>
<div class="section" id="resetting-system-service-log-levels">
<span id="http-restful-api-system-service-logging-resetting"></span><h3>Resetting System Service Log Levels<a class="headerlink" href="#resetting-system-service-log-levels" title="Permalink to this headline">🔗</a></h3>
<p>Resetting the log levels will change the log levels back to what they were when the system
service was started.</p>
<p>To reset the log levels of a system service, at runtime under Distributed CDAP mode, submit
an HTTP PUT request:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">POST /v3/system/services/&lt;service-id&gt;/resetloglevels</span>
</pre></div>
</div>
<p>with an optional JSON array in the request body consisting of the logger names to be
reset, such as:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">&#39;[ &quot;io.cdap.cdap&quot;, &quot;ROOT&quot; ]&#39;</span>
</pre></div>
</div>
<p>If the body is not provided or is empty, it will reset the log levels of all logger names.</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">service-id</span></code></td>
<td>One of <code class="docutils literal notranslate"><span class="pre">appfabric</span></code>, <code class="docutils literal notranslate"><span class="pre">dataset.executor</span></code>, <code class="docutils literal notranslate"><span class="pre">explore.service</span></code>, <code class="docutils literal notranslate"><span class="pre">log.saver</span></code>,
<code class="docutils literal notranslate"><span class="pre">messaging.service</span></code>,``metrics``, <code class="docutils literal notranslate"><span class="pre">metrics.processor</span></code>, <code class="docutils literal notranslate"><span class="pre">streams</span></code>, <code class="docutils literal notranslate"><span class="pre">transaction</span></code></td>
</tr>
</tbody>
</table>
<p>Note that resetting the log levels of the <code class="docutils literal notranslate"><span class="pre">appfabric</span></code> service <strong>will also</strong> rest the
log levels of the <code class="docutils literal notranslate"><span class="pre">dataset.service</span></code> as they run on the same node.</p>
<p>For example:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">POST /v3/system/services/metrics.processor/resetloglevels \</span>
<span class="go">    -d &#39;[ &quot;io.cdap.cdap&quot;, &quot;ROOT&quot; ]&#39;</span>
</pre></div>
</div>
<p>will reset the log level of the system service <em>metrics.processor</em> with log levels of
<code class="docutils literal notranslate"><span class="pre">io.cdap.cdap</span></code> and <code class="docutils literal notranslate"><span class="pre">ROOT</span></code> reset back to what they were when the <em>metrics.processor</em>
service was started.</p>
</div>
</div>
<div class="section" id="changing-program-log-levels">
<span id="http-restful-api-logging-changing-program-log-levels"></span><h2>Changing Program Log Levels<a class="headerlink" href="#changing-program-log-levels" title="Permalink to this headline">🔗</a></h2>
<p>Log levels can be set for a particular run of a program. Once changed, they can be reset back to what
they started with by using the <a class="reference internal" href="#http-restful-api-program-logging-resetting"><span class="std std-ref">program reset endpoint</span></a>
shown below.</p>
<p><strong>Note:</strong> The log levels can only be changed dynamically for programs that are running under Distributed CDAP.
Currently, only flows, services, or workers are supported.</p>
<div class="section" id="setting-program-log-levels">
<h3>Setting Program Log Levels<a class="headerlink" href="#setting-program-log-levels" title="Permalink to this headline">🔗</a></h3>
<p>To set the log levels of a program run at runtime under Distributed CDAP, submit an HTTP PUT request:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">PUT /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/&lt;program-type&gt;/&lt;program-id&gt;/runs/&lt;run-id&gt;/loglevels</span>
</pre></div>
</div>
<p>To set the log levels of a program run in a particular version of an application:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">PUT /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/versions/&lt;version-id&gt;/&lt;program-type&gt;/&lt;program-id&gt;/runs/&lt;run-id&gt;/loglevels</span>
</pre></div>
</div>
<p>To set the log levels of a flowlet in the run of a flow:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">PUT /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/flows/&lt;flow-id&gt;/flowlet/&lt;flowlet-id&gt;/runs/&lt;run-id&gt;/loglevels</span>
</pre></div>
</div>
<p>To set the log levels of a flowlet in the run of a flow in a particular version of an application:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">PUT /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/versions/&lt;version-id&gt;/flows/&lt;flow-id&gt;/flowlet/&lt;flowlet-id&gt;/runs/&lt;run-id&gt;/loglevels</span>
</pre></div>
</div>
<p>and, in all cases, with a JSON map in the request body consisting of pairs of logger names and log levels, such as:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">&#39;{ &quot;io.cdap.cdap&quot;:&quot;ERROR&quot;, &quot;ROOT&quot;:&quot;TRACE&quot; }&#39;</span>
</pre></div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">namespace-id</span></code></td>
<td>Namespace ID</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">app-id</span></code></td>
<td>Name of the application</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">version-id</span></code></td>
<td>Version of the application</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">program-type</span></code></td>
<td>One of <code class="docutils literal notranslate"><span class="pre">flows</span></code>, <code class="docutils literal notranslate"><span class="pre">services</span></code>, or <code class="docutils literal notranslate"><span class="pre">workers</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">program-id</span></code></td>
<td>Name of the program</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">flow-id</span></code></td>
<td>Name of the flow</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">flowlet-id</span></code></td>
<td>Name of the flowlet</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">run-id</span></code></td>
<td>UUID of the program run</td>
</tr>
</tbody>
</table>
<p>For example:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">PUT /v3/namespaces/default/apps/SportResults/services/UploadService/run-id/cdec1791-c2c0-11e6-ac6b-42010a800022/loglevels \</span>
<span class="go">    -d &#39;{ &quot;io.cdap.cdap&quot;:&quot;ERROR&quot;, &quot;ROOT&quot;:&quot;TRACE&quot; }&#39;</span>
</pre></div>
</div>
<p>will update the log levels of the service <em>UploadService</em> in the <em>SportResults</em> application with
the log level of <code class="docutils literal notranslate"><span class="pre">io.cdap.cdap</span></code> changed to <code class="docutils literal notranslate"><span class="pre">ERROR</span></code>
and log level of <code class="docutils literal notranslate"><span class="pre">ROOT</span></code> changed to <code class="docutils literal notranslate"><span class="pre">TRACE</span></code>.</p>
</div>
<div class="section" id="resetting-program-log-levels">
<span id="http-restful-api-program-logging-resetting"></span><h3>Resetting Program Log Levels<a class="headerlink" href="#resetting-program-log-levels" title="Permalink to this headline">🔗</a></h3>
<p>Resetting the log levels will change the log levels back to what they were when the program was started.</p>
<p>To reset the log levels of a program run at runtime under Distributed CDAP mode, submit an HTTP PUT request:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">POST /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/&lt;program-type&gt;/&lt;program-id&gt;/runs/&lt;run-id&gt;/resetloglevels</span>
</pre></div>
</div>
<p>To reset the log levels of a program run in a particular version of an application:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">POST /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/versions/&lt;version-id&gt;/&lt;program-type&gt;/&lt;program-id&gt;/runs/&lt;run-id&gt;/resetloglevels</span>
</pre></div>
</div>
<p>To reset the log levels of a flowlet in the run of a flow:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">POST /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/flows/&lt;flow-id&gt;/flowlet/&lt;flowlet-id&gt;/runs/&lt;run-id&gt;/resetloglevels</span>
</pre></div>
</div>
<p>To reset the log levels of a flowlet in the run of a flow in a particular version of an application:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">POST /v3/namespaces/&lt;namespace-id&gt;/apps/&lt;app-id&gt;/versions/&lt;version-id&gt;/flows/&lt;flow-id&gt;/flowlet/&lt;flowlet-id&gt;/runs/&lt;run-id&gt;/resetloglevels</span>
</pre></div>
</div>
<p>and, in all cases, with an optional JSON array in the request body consisting of the logger names to be reset, such as:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">&#39;[ &quot;io.cdap.cdap&quot;, &quot;ROOT&quot; ]&#39;</span>
</pre></div>
</div>
<p>If the body is not provided or is empty, it will reset the log levels of all logger names.</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">namespace-id</span></code></td>
<td>Namespace ID</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">app-id</span></code></td>
<td>Name of the application</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">version-id</span></code></td>
<td>Version of the application</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">program-type</span></code></td>
<td>One of <code class="docutils literal notranslate"><span class="pre">flows</span></code>, <code class="docutils literal notranslate"><span class="pre">services</span></code>, or <code class="docutils literal notranslate"><span class="pre">workers</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">program-id</span></code></td>
<td>Name of the program</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">flow-id</span></code></td>
<td>Name of the flow</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">flowlet-id</span></code></td>
<td>Name of the flowlet</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">run-id</span></code></td>
<td>UUID of the program run</td>
</tr>
</tbody>
</table>
<p>For example:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">POST /v3/namespaces/default/apps/SportResults/services/UploadService/run-id/cdec1791-c2c0-11e6-ac6b-42010a800022/resetloglevels \</span>
<span class="go">    -d &#39;[ &quot;io.cdap.cdap&quot;, &quot;ROOT&quot; ]&#39;</span>
</pre></div>
</div>
<p>will reset the log level of the service <em>UploadService</em> in the <em>SportResults</em> application
with the log levels of <code class="docutils literal notranslate"><span class="pre">io.cdap.cdap</span></code> and <code class="docutils literal notranslate"><span class="pre">ROOT</span></code> reset back to
what they were when the flow was started.</p>
</div>
</div>
</div>

</div>
    <div class="col-md-2">
      <div id="right-sidebar" class="bs-sidenav scrollable-y" role="complementary">
        <div id="localtoc-scrollspy">
        </div>
      </div>
    </div></div>
</div>
<!-- block main content end -->
<!-- block footer -->
<footer class="footer">
      <div class="container">
        <div class="row">
          <div class="col-md-2 footer-left"><a title="Lifecycle HTTP RESTful API" href="lifecycle.html" />Previous</a></div>
          <div class="col-md-8 footer-center"><a class="footer-tab-link" href="../table-of-contents/../../reference-manual/licenses/index.html">Copyright</a> &copy; 2014-2020 Cask Data, Inc.&bull; <a class="footer-tab-link" href="//docs.cask.co/cdap/6.1.1/cdap-docs-6.1.1-web.zip" rel="nofollow">Download</a> an archive or
<a class="footer-tab-link" href="//docs.cask.co/cdap">switch the version</a> of the documentation
          </div>
          <div class="col-md-2 footer-right"><a title="Metadata HTTP RESTful API" href="metadata.html" />Next</a></div>
        </div>
      </div>
    </footer>
<!-- block footer end -->
<script type="text/javascript" src="../_static/bootstrap-3.3.6/js/bootstrap.min.js"></script><script type="text/javascript" src="../_static/js/bootstrap-sphinx.js"></script><script type="text/javascript" src="../_static/js/abixTreeList-2.js"></script><script type="text/javascript" src="../_static/js/cdap-dynamicscrollspy-4.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script><script type="text/javascript" src="../_static/js/copy-to-clipboard.js"></script><script type="text/javascript" src="../_static/js/jquery.mousewheel.min.js"></script><script type="text/javascript" src="../_static/js/jquery.mCustomScrollbar.js"></script><script type="text/javascript" src="../_static/js/js.cookie.js"></script><script type="text/javascript" src="../_static/js/tabbed-parsed-literal-0.2.js"></script><script type="text/javascript" src="../_static/js/cdap-onload-javascript.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script>
    <script src="https://cdap.gitee.io/docs/cdap/json-versions.js"/></script>
  </body>
</html>